/*******************************************************************************
 * Copyright 2011 Mile Orešković
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.mileoresko.hsm.examples.phone;

import com.mileoresko.hsm.HSMState;

public abstract class PhoneState extends HSMState {

    public static final PhoneState IDLE = new PhoneState("IDLE") {
        protected void exitAction(final Object arg) {
        }

        public void entryAction(final Object arg) {

        }
    };

    public static final PhoneState CONNECTING = new PhoneState("CONNECTING") {
        public void entryAction(final Object arg) {
            final String userId = (String) arg;
            owningStateMachine.smLog("Connecting to " + userId);
        }

        public void exitAction(final Object arg) {

        }
    };

    public static final PhoneState DIALING = new PhoneState("DIALING") {

        protected void entryAction(final Object arg) {
            final String userId = (String) arg;
            owningStateMachine.smLog("Dialing to " + userId);
        }

        protected void exitAction(final Object arg) {
        }

    };

    public static final PhoneState RINGING_BACK = new PhoneState("RINGING_BACK") {

        protected void entryAction(final Object arg) {
        }

        protected void exitAction(final Object arg) {
        }

    };

    public static final PhoneState INCOMING = new PhoneState("INCOMING") {

        protected void entryAction(final Object arg) {
        }

        protected void exitAction(final Object arg) {
        }

    };

    public static final PhoneState IN_CALL = new PhoneState("IN_CALL") {

        protected void entryAction(final Object arg) {
        }

        protected void exitAction(final Object arg) {
        }

    };

    protected PhoneState(final String label) {
        super(Phone.getStateMachine(), label);
    }

    protected void defineNestedHsms() {
        // all states have no nested HSMs
    }
}
